package com.etc.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.etc.dao.FoodsMapper;
import com.etc.entity.Foods;
import com.etc.entity.RFoods;
import com.etc.service.FoodsService;
@Service(value="foodsService")
public class FoodsServiceImpl implements FoodsService {
	@Resource
	private FoodsMapper foodsMapper;
	/**
	 * 根据rid查询食物信息
	 */
	@Override
	public List<RFoods> getFoodsAllByRid(Integer rid) {
		
		return foodsMapper.getFoodsAllByRid(rid);
	}
	@Override
	public List<RFoods> getFoodsAll() {
		
		return foodsMapper.getFoodsAll();
	}
	@Override
	public boolean addfoods(Foods foods) {
		
		return foodsMapper.insertSelective(foods)>0;
	}
	@Override
	public boolean delfoodsByFid(int fid) {
		
		return foodsMapper.deleteByPrimaryKey(fid)>0;
	}
	@Override
	public boolean updatafoods(Foods foods) {
		
		return foodsMapper.updateByPrimaryKeySelective(foods)>0;
	}
	@Override
	public List<RFoods> getFoodsByPage(Integer page, Integer limit,Integer rid) {
		int start = (page-1)*limit;
		return foodsMapper.getFoodsAllByPage(start,limit,rid);
	}
	@Override
	public int getcount(Integer rid) {
		
		return foodsMapper.getcount(rid);
	}

}
